﻿import com.dmotiko.general.*

class FormFieldValidator {
	
	public static function notEmpty( text:String ):Boolean {
		return text.length > 0;
	}
	public static function inRange( text:String, min:Number, max:Number ):Boolean {
		if (!min) min = 0;
		if ( !max) max = text.length;
		return text.length >= min && text.length <= max;
	}
	public static function mail( text:String ):Boolean {
		if ( !notEmpty( text ) ) return false;
		var nAt:Number = text.indexOf("@");
		var bAt:Boolean = text.lastIndexOf("@") == nAt;
		var nDot:Number = text.lastIndexOf(".");
		return ( nDot > nAt && nAt > 3 && nDot < text.length );
	}
	
}